﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CommunicateBetweenJsAndCSharp
{
    using Chromium;
    using Grpc.Core;
    using GRPCDemo;
    using NetDimension.NanUI;

	static class Program
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main()
		{
            const int Port = 50051;
            string Host = Helper.GetIPV4();//绑定本地ip
            //启动RPC服务
            Server server = new Server
            {
                Services = { rpcSite.BindService(new RpcSiteImpl()) },
                Ports = { new ServerPort(Host, Port, ServerCredentials.Insecure) }
            };
            server.Start();

            Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			if (Bootstrap.Load())
			{
                //Bootstrap.RegisterAssemblyResources(System.Reflection.Assembly.GetExecutingAssembly());
                //注册嵌入资源，并为指定资源指定一个假的域名my.resource.local
                Bootstrap.RegisterAssemblyResources(System.Reflection.Assembly.GetExecutingAssembly(), "www", "res.app.local");
                Application.Run(new Form1());
			}
		}

        static Action<CfxSettings> Settings()
        {
            return settings =>
            {
                settings.LogSeverity = CfxLogSeverity.Disable;//禁用日志

                //指定中文为当前CEF环境的默认语言
                settings.AcceptLanguageList = "zh-CN";
                settings.Locale = "zh-CN";
            };
        }
        static Action<CfxCommandLine> CommandLine()
        {
            return commandLine =>
            {
                //在启动参数中添加disable-web-security开关，禁用跨域安全检测
                commandLine.AppendSwitch("disable-web-security");
            };
        }

    }
}
